﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenMUD.Mudlib.lib.Loc;
using System.IO;

namespace Open_MUD.Mudlib.lib.Loc
{
    class Map:MUDObject
    {
        protected int ancho;
        protected int alto;
        protected Room[][] Rooms;
        //para conectarse entre mapas:
        Salida[] Salidas;

        public virtual Room InstanceRoom(int x, int y)
        {
            return null;
        }

        public virtual Room GetRoom(int x, int y)
        {
            if (x < 0 || x > this.ancho || y < 0 || y > alto)
                return null;
            if (Rooms[x][y] == null)
            {
                return InstanceRoom(x, y);
            }
            return Rooms[x][y];
        }

        protected virtual void init()
        {
            Rooms = new Room[ancho][];
            for(int i=0 ; i < ancho ; i++ )
                Rooms[i] = new Room[alto];
        }

        public virtual void CreateMap(string name, string xmlconfig, int maxx, int maxy)
        {
            this.Nombre = name;
            ancho = maxx;
            alto = maxy;
            init(); 
        }

        protected void AddSalida(Room r1, Room r2, string s1, string s2)
        {
            //TODO
        }
    }
}
